#!/bin/bash

echo "🔍 检查Django后端状态..."

# 检查Django后端是否运行
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/api/health/ 2>/dev/null)

if [ $? -eq 0 ] && [ "$response" = "200" ]; then
    echo "✅ Django后端运行正常 (HTTP $response)"
    
    # 测试登录接口
    echo "🔐 测试登录接口..."
    login_response=$(curl -s -X POST \
        -H "Content-Type: application/json" \
        -d '{"username":"test","password":"test123"}' \
        http://localhost:8000/api/auth/login/ 2>/dev/null)
    
    if [ $? -eq 0 ]; then
        echo "✅ 登录接口响应: $login_response"
    else
        echo "❌ 登录接口测试失败"
    fi
else
    echo "❌ Django后端未运行或无法访问"
    echo "请运行: cd d:/hmm && python manage.py runserver 8000"
fi